package com.lsc.fegin;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.alibaba.fastjson.JSON;
import com.lsc.admin.demo.api.UserService;
import com.lsc.fegin.service.FeginUserService;
import com.smf.lsc.core.exception.BaseException;
import com.smf.lsc.core.respones.Result;
import com.smf.lsc.core.respones.ResultUtil;
import com.smf.lsc.security.util.AuthUserUtil;

@RestController
@RequestMapping("/fegin")
public class DemoController {
	
//	@Value("${config}")
//	private String configCenterTest;
	
	@Autowired
	UserService userService;
	@Autowired 
	FeginUserService feginUserService;
	
	@RequestMapping("/callAdmin")
    public Result<String> getFegin() throws BaseException {
		//1、调用远程admin服务接口
        return userService.getFegin();
    }
	@RequestMapping("/callAdminUser")
    public Result<String> getFeginUser() throws BaseException {
		//1、调用远程admin服务接口
        return userService.getCurrentUser();
    }
	
	@RequestMapping(value = "/getCurrentUser")
	public Result<String> getCurrentUser() {
		//2、获取当前登录用户信息
		String currentUserJson=JSON.toJSONString(AuthUserUtil.getCurrentUser());
		return ResultUtil.successResult(currentUserJson+"==admin登录用户:"+currentUserJson, "");
	}
	
	@RequestMapping(value = "/permis")
	public Result<String> checkPermis() {
		return ResultUtil.successResult("白名单通过成功", "");
	}
	
	@RequestMapping(value = "/dtpinsert")
	public Result<Boolean> dtpInsert() {
		boolean l=feginUserService.save();
		return ResultUtil.successResult(l,"保存成功");
	}
	
	@RequestMapping("/callDtpInsert")
    public Result<String> callInsertUser() throws BaseException {
		//1、调用远程admin服务接口
		boolean l= feginUserService.callAdminInsert();
        return ResultUtil.successResult(l,"保存成功");
    }
}
